﻿using Microsoft.AspNetCore.Mvc;
using Microsoft.EntityFrameworkCore;
using System.Xml;
using 天离安全_天擎.Tl_EntitySqlIte;
using 天离安全_天擎.Tl_SerVices;

namespace 天离安全_天擎.Controllers.Crack_Controller
{
    /// <summary>
    /// sql密码爆破
    /// </summary>
    [ApiController]
    [Route("[controller]")]
    public class CrackSqlPassWordController : Controller
    {
        private readonly Tl_SerVices.CrackPassWord_Services _crackPassWordServices;
        /// <summary>
        /// 注册服务
        /// </summary>
        /// <param name="crackPassWordServices"></param>
        public CrackSqlPassWordController(Tl_SerVices.CrackPassWord_Services crackPassWordServices)
        {
            _crackPassWordServices = crackPassWordServices;
        }
        /// <summary>
        /// 获取mysql数据库弱口令密码列表
        /// </summary>
        /// <param name="page"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        [HttpPost("get")]
        public async Task<ActionResult<object>> GetPasswords([FromQuery] int page = 1, [FromQuery] int pageSize = 100)
        {
            var (items, totalCount) = await _crackPassWordServices.GetMysqlPasswordsAsync(page, pageSize);

            var result = new
            {
                TotalCount = totalCount,
                Page = page,
                PageSize = pageSize,
                Items = items
            };

            return Ok(result); // 返回状态200和数据
        }
    }
}
